package com.exam.controller;

import com.exam.pojo.ApiResult;
import com.exam.pojo.JudgeQuestion;
import com.exam.service.JudgeQuestionService;
import com.exam.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JudgeQuestionController {
    @Autowired
    private JudgeQuestionService judgeQuestionService;
    @GetMapping("/judgeQuestionId")
    public ApiResult findOnlyQuestionId(){
        JudgeQuestion res=judgeQuestionService.findOnlyQuestionId();
        if (res!=null){
               return ApiResultHandler.buildApiResult(200, "查询成功", res);
        }
        return ApiResultHandler.buildApiResult(400, "查询失败", res);
    }
    @PostMapping("judgeQuestion")
    public ApiResult add(@RequestBody JudgeQuestion judgeQuestion ){
        int res=judgeQuestionService.add(judgeQuestion);
        if(res!=0){
            return ApiResultHandler.buildApiResult(200, "添加成功", res);
        }
        return ApiResultHandler.buildApiResult(400, "添加失败", res);
    }
}
